//
//  WZCompanyInfoCell.m
//  ETong
//
//  Created by wanzhao on 15/10/30.
//  Copyright (c) 2015年 wanzhao. All rights reserved.
//

#import "WZCompanyInfoCell.h"
#import "WZComInfoFram.h"

@interface WZCompanyInfoCell ()

@property (nonatomic, weak) UILabel *nameLabel;
@property (nonatomic, weak) UILabel *addressLabel;
@property (nonatomic, weak) UILabel *telLabel;
@property (nonatomic, weak) UILabel *faxLabel;

@property (nonatomic, weak) UIView *line1;
@property (nonatomic, weak) UIView *line2;


@end

@implementation WZCompanyInfoCell


+ (WZCompanyInfoCell *)companyInfoCellWithTableView:(UITableView *)tableView
{
    static NSString *comCellId = @"comCell";
    WZCompanyInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:comCellId];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:comCellId];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = ClearColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setupComCellSubView];
        
    }
    return self;
}

- (void)setupComCellSubView
{
    UIView *line1 = [[UIView alloc] init];
    line1.backgroundColor = RGBCOLORWITH16COLOR(0xffffff);
    [self.contentView addSubview:line1];
    self.line1 = line1;
    
    UIView *line2 = [[UIView alloc] init];
    line2.backgroundColor = RGBCOLORWITH16COLOR(0xd4d4d4);
    [self.contentView addSubview:line2];
    self.line2 = self.line2;
    
    
    UILabel *nameLabel = [self addLabelWithFont:Font15 textAliment:NSTextAlignmentLeft textColor:RGBCOLORWITH16COLOR(0x666666)];
    self.nameLabel = nameLabel;
    
    UILabel *addLabel = [self addLabelWithFont:Font15 textAliment:NSTextAlignmentLeft textColor:RGBCOLORWITH16COLOR(0x666666)];
    self.addressLabel = addLabel;
    
    UILabel *telLabel = [self addLabelWithFont:Font15 textAliment:NSTextAlignmentLeft textColor:RGBCOLORWITH16COLOR(0x666666)];
    self.telLabel = telLabel;
    
    UILabel *faxLabel = [self addLabelWithFont:Font15 textAliment:NSTextAlignmentLeft textColor:RGBCOLORWITH16COLOR(0x666666)];
    self.faxLabel = faxLabel;
    
}

- (UILabel *)addLabelWithFont:(UIFont *)textFont textAliment:(NSTextAlignment)textAliment textColor:(UIColor *)textColor
{
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.font = textFont;
    nameLabel.textAlignment = textAliment;
    nameLabel.numberOfLines = 0;
    nameLabel.textColor = textColor;
    [self.contentView addSubview:nameLabel];
    return nameLabel;
}

- (void)setComInfoFrame:(WZComInfoFram *)comInfoFrame
{
    _comInfoFrame = comInfoFrame;
    self.nameLabel.text = [NSString stringWithFormat:@"%@：",comInfoFrame.comInfo.companyName];
    self.nameLabel.frame = comInfoFrame.nameFrame;
    
    self.addressLabel.text = [NSString stringWithFormat:@"地址：%@",comInfoFrame.comInfo.companyAddress];
    self.addressLabel.frame = comInfoFrame.addFrame;
    
    self.telLabel.text = [NSString stringWithFormat:@"电话：%@",comInfoFrame.comInfo.companyTelePhone];
    self.telLabel.frame = comInfoFrame.telFrame;
    
    self.faxLabel.text = [NSString stringWithFormat:@"传真：%@",comInfoFrame.comInfo.companyFax];
    self.faxLabel.frame = comInfoFrame.faxFrame;
    
    self.line1.frame = comInfoFrame.line1Frame;
    self.line2.frame = comInfoFrame.line2Frame;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
}

@end
